﻿using DemoImportDll;

// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");

//while (true)
//{
//    //var testptr = DemoDll.CreateTest();
//    //DemoDll.AllocSpace(testptr, 1024 * 1024);
//    //DemoDll.ReleaseSpace(testptr);
//    //DemoDll.ReleaseTest(testptr);
//    SafeTest.AllocSpace(1024 * 1024);
//    Thread.Sleep(200);
//}


var startTime = DateTime.Now;
var endTime = DateTime.Now;



var v1 = 2333.3333;
var count = 2000;
var loopCount = 1000000;

// 原生 C++ ，但是 .NET 的循环
var testptr = DemoDll.CreateTest();
startTime = DateTime.Now;
for (int i = 0; i < loopCount; i++)
{
    var r1 = DemoDll.Pow(testptr, v1, count);
}
endTime = DateTime.Now;
DemoDll.ReleaseTest(testptr);
Console.WriteLine(endTime - startTime);


// 纯 .NET 的循环
startTime = DateTime.Now;
for (int i = 0; i < loopCount; i++)
{
    var r2 = SafeTest.Pow(v1, count);
}
endTime = DateTime.Now;
Console.WriteLine(endTime - startTime);

// 纯原生 C++
var testptr2 = DemoDll.CreateTest();
startTime = DateTime.Now;
var r3 = DemoDll.PowLoop(testptr2, v1, count, loopCount);
endTime = DateTime.Now;
Console.WriteLine(endTime - startTime);
DemoDll.ReleaseTest(testptr2);

